sudo apt install -y python3-libcamera python3-kms++ python3-picamera2

if error occured due to above code run below commands:
ps aux | grep apt
sudo kill -9 ID (id is the process that holds the dpkg, id obtained from the 1st command)